#ifndef REMOTE_FUNCTIONS_H_
#define REMOTE_FUNCTIONS_H_

#include "../lib/cJSON.h"
#include "../common/common.h"

// Each remote function receives a cJSON parameter array and returns a cJSON result.
// This unified signature simplifies the dispatcher's job.
// The error_code output parameter is used for robust error handling.

/**
 * @brief Remote function: Adds two numbers.
 * Expects a JSON array with two numbers: [num1, num2].
 * @param params The cJSON array of parameters.
 * @param error_code Pointer to store an error code if validation fails.
 * @return A cJSON number with the sum, or NULL on error.
 */
cJSON* remote_add(const cJSON* params, RpcErrorCode* error_code);

/**
 * @brief Remote function: Retrieves a mock user profile.
 * Expects a JSON array with one string: ["username"].
 * @param params The cJSON array of parameters.
 * @param error_code Pointer to store an error code.
 * @return A cJSON object representing a UserProfile, or NULL on error.
 */
cJSON* remote_get_user_info(const cJSON* params, RpcErrorCode* error_code);

/**
 * @brief Remote function: Sums numbers from a variadic list of parameters.
 * Expects a JSON array of any length, containing numbers and other types.
 * It will sum the numbers and ignore other types.
 * @param params The cJSON array of parameters.
 * @param error_code Pointer to store an error code.
 * @return A cJSON number with the total sum, or NULL on error.
 */
cJSON* remote_sum_and_print(const cJSON* params, RpcErrorCode* error_code);

/**
 * @brief Remote function: Processes a user profile struct sent from the client.
 * Expects a JSON array with one object: [{ "name": "...", "age": ..., "city": "..."}].
 * @param params The cJSON array of parameters.
 * @param error_code Pointer to store an error code.
 * @return A cJSON string confirming receipt, or NULL on error.
 */
// <-- THIS FUNCTION DECLARATION WAS ADDED ---
cJSON* remote_process_user_profile(const cJSON* params, RpcErrorCode* error_code);


#endif  // REMOTE_FUNCTIONS_H_

